<!--
 * @name: 商家推荐
 * @version: 1.1.1
 * @Author: 刘大可
 * @Date: 2022-07-19 12:14:53
 * @LastEditors: 刘大可
 * @LastEditTime: 2022-10-25 17:03:30
-->
<template>
    <view class="navs flex margin-lr">
        <block v-for="(item,index) in list" :key="index">
            <view class="nav" @click="go('/gc_school/pages/canteen/list?type_id='+item.type_id)">
                <image class="icon" :src="item.type_image" mode="scaleToFill" />
                {{item.type_name}}
            </view>
        </block>
    </view>
</template>

<script>
var app = getApp();
export default {
    data() {
        return {
            sys: {},
            list: [],

            authData: {}
        }
    },
    props: {
        // 即将弃用
        schoolInfo: {
            type: [Object, Array, String],
            default() {
                return {};
            }
        },
    },
    created() {

        this.initData() 
        // if (uni.getStorageSync('token')) {
        //     this.getAuth()
        // }
    },
    methods: {

        async initData() {
            var that = this;
            var shcool_id = uni.getStorageSync('schoolId');
            app.globalData.util.request({
                url: 'ZhBusinesType/index',
                method: 'GET',
                data: {
                    s_id: shcool_id
                },
                success(res) {
                    if (res.data.status == 200) {
                        that.list = [
                            ...res.data.data.list,
                        ]
                        if (res.data.data.list.length > 0) {
                            // that.getStore();
                        }
                    }
                }
            });

        },
        goStore(e) {
            try {
                uni.setStorageSync('module_id', this.schoolInfo.default_store_module.id)
            } catch (error) {

            }
            this.go(e)
        }
    }
}
</script>
<style lang="scss">
@import "./main.scss";
</style>